﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace GBSHouse.UptimeRobot {
	public class UptimeRobotContactCollectionResponse {

		/// <summary>
		/// Gets or sets the status.
		/// </summary>
		/// <value>
		/// The status.
		/// </value>
		[JsonProperty("stat")]
		public string Status { get; set; }

		/// <summary>
		/// Gets or sets the contacts.
		/// </summary>
		/// <value>
		/// The contacts.
		/// </value>
		[JsonProperty("alertcontacts")]
		public UptimeRobotContactCollectionResponseContact Contacts { get; set; }

		/// <summary>
		/// Gets or sets the contact list.
		/// </summary>
		/// <value>
		/// The contact list.
		/// </value>
		[JsonIgnore]
		public List<UptimeRobotContact> ContactList {
			get { return this.Contacts.Contact; }
			set { this.Contacts.Contact = value; }
		}

		/// <summary>
		/// Gets a value indicating whether this <see cref="UptimeRobotContactCollectionResponse"/> is success.
		/// </summary>
		/// <value>
		///   <c>true</c> if success; otherwise, <c>false</c>.
		/// </value>
		[JsonIgnore]
		public bool Success {
			get { return this.Status.Equals("ok", StringComparison.InvariantCultureIgnoreCase); }
		}

		public UptimeRobotContactCollectionResponse() {
			this.Contacts = new UptimeRobotContactCollectionResponseContact();
		}

		public class UptimeRobotContactCollectionResponseContact {

			/// <summary>
			/// Gets or sets the contact.
			/// </summary>
			/// <value>
			/// The contact.
			/// </value>
			[JsonProperty("alertcontact")]
			public List<UptimeRobotContact> Contact {get;set;}

			public UptimeRobotContactCollectionResponseContact() {
				this.Contact = new List<UptimeRobotContact>();
			}
		}
	}
}
